<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加标签</title>
</head>
<body>

<form class="layui-form" lay-filter="layui-form">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label"><text title="必填项" style="color:red;">*</text>标签名称</label>
                    <div class="layui-input-block">
                        <input type="text"  name="value" lay-verify="required" autocomplete="off" placeholder="请输入玩法名称" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">文字颜色</label>
                    <div style="margin-left: 30px;">
                        <div id="value_color_dom"></div>
                        <input type="hidden" name="value_color" id="value_color" value="" />
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">背景颜色</label>
                    <div style="margin-left: 30px;">
                        <div id="bg_color_dom"></div>
                        <input type="hidden" name="bg_color" id="bg_color" value="" />
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="laytp-btn laytp-btn-primary laytp-btn-sm" lay-submit="" lay-filter="add">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="laytp-btn laytp-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script>
    if(localStorage.getItem("staticDomain")){
        document.write("<link rel='stylesheet' href='" + localStorage.getItem("staticDomain") + "/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery_3.3.1.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='" + localStorage.getItem("staticDomain") + "/component/jquery.tablednd.js?v="+localStorage.getItem("version")+"'><\/script>");
    }else{
        document.write("<link rel='stylesheet' href='/static/component/layui/css/layui.css?v=" + localStorage.getItem("version") + "'>");
        document.write("<script src='/static/component/layui/layui.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/laytp/layuiConfig.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/jquery_3.3.1.js?v="+localStorage.getItem("version")+"'><\/script>");
        document.write("<script src='/static/component/jquery.tablednd.js?v="+localStorage.getItem("version")+"'><\/script>");
    }
</script>
<script>
    layui.use(['laytp','colorpicker'],function(){
        let $ = layui.jquery;
        let colorpicker = layui.colorpicker;
        let element = layui.element;
        //常规使用
        colorpicker.render({
            elem: '#value_color_dom' //绑定元素
            ,change: function(color){ //颜色改变的回调
                /*layer.tips('选择了：'+ color, this.elem, {
                    tips: 1
                });*/

                $('#value_color').val(color);

            }
        });


        //常规使用
        colorpicker.render({
            elem: '#bg_color_dom' //绑定元素
            ,change: function(color){ //颜色改变的回调
                /*layer.tips('选择了：'+ color, this.elem, {
                    tips: 1
                });*/

                $('#bg_color').val(color);

            }
        });
        layui.form.on('submit(add)', function(data){
            var btnAnim = layui.button.load({elem:$(this)});
            facade.ajax({
                route:'/admin.ah.label/add',
                data : data.field
            }).done(function(res){
                if(res.code === 0){
                    parent.layui.layer.close(parent.layui.layer.getFrameIndex(window.name));//关闭当前页
                    parent.layui.table.reload("laytp-table");
                }
                btnAnim.stop();
            }).fail(function(){
                btnAnim.stop();
            });
            return false;
        });
    })
</script>
</body>
</html>